package cn.tedu.demo.controller;
import cn.tedu.demo.mapper.UserInfoMapper;
import cn.tedu.demo.pojo.dto.OrderAddNewDTO;
import cn.tedu.demo.pojo.dto.UserInfoDTO;
import cn.tedu.demo.pojo.vo.UserInfoVO;
import cn.tedu.demo.pojo.vo.UserVO;
import cn.tedu.demo.service.IUserInfoService;
import cn.tedu.demo.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
@Slf4j
@RestController
@RequestMapping("/customercenter")
@Api(tags = "1.用户信息板块")
public class UserInfoController {

    @Autowired
    IUserInfoService userInfoService;

    @GetMapping("/info")
    @ApiOperation("4.查询客户信息")
    @ApiOperationSupport(order = 400)
    public JsonResult<UserInfoVO> getInfoByUserId(HttpSession session ){
        log.debug("开始处理【查询信息】的请求，参数：通过session:{}获取",session);
        UserInfoVO queryResult = userInfoService.getInfoByUserId(session);
        log.debug("返回对象:{}",queryResult);
        return JsonResult.ok(queryResult);
    }

    @PostMapping("/update")
    @ApiOperation("3.更改客户信息")
    @ApiOperationSupport(order = 300)
    public JsonResult<Void> update(UserInfoDTO userInfoDTO, HttpSession session){
        log.debug("开始处理【更改信息】的请求，入参参数:{},session:{}",userInfoDTO,session);
        userInfoService.update(userInfoDTO,session);
        return JsonResult.ok();
    }



}
